﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TravelRecordForm.aspx.cs"
    Inherits="YhmOA.Integrated.Car.TravelRecordForm" %>

<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.1, Version=10.1.6.0, Culture=neutral, PublicKeyToken=c6bed6029ccaee5e"
    Namespace="DevExpress.Web.ASPxLoadingPanel" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link type="text/css" rel="Stylesheet" href="../../Styles/Common.css" />
    <script type="text/javascript" src="../../Scripts/jquery-1.5.2.min.js"></script>
    <script type="text/javascript" src="../../Scripts/include.jquery.js"></script>
    <script type="text/javascript" src="../../Scripts/Common.js"></script>
    <script src="../../Scripts/DevEx.js" type="text/javascript"></script>
    <script type="text/javascript">
        function OnPlateNumChanged(s, e) {
            cbPlateNumCtrl.PerformCallback(txt_PlateNumCtrl.GetText());
        };
        function OnDirectionChanged(s, e) {
            if (txt_DirectionCtrl.GetSelectedIndex() > -1) {
                txt_DrivingLineCtrl.SetText(txt_DirectionCtrl.GetValue());
            } else {
                txt_DrivingLineCtrl.SetText('');
            }
        };
        function OnSendMileageChanged(s, e) {
            if (parseFloat(txt_ReturnMileageCtrl.GetText()) > 0 && parseFloat(txt_SendMileageCtrl.GetText()) > 0) {
                txt_CurrentMileageCtrl.SetText((parseFloat(txt_ReturnMileageCtrl.GetText()).toFixed(4)-0) - (parseFloat(txt_SendMileageCtrl.GetText()).toFixed(4)-0));
            }
        };
        function OnReturnMileageChanged(s, e) {
            if (parseFloat(txt_ReturnMileageCtrl.GetText()) > 0 && parseFloat(txt_SendMileageCtrl.GetText()) > 0) {
                txt_CurrentMileageCtrl.SetText((parseFloat(txt_ReturnMileageCtrl.GetText()).toFixed(4)-0) - (parseFloat(txt_SendMileageCtrl.GetText()).toFixed(4)-0));
            }
        };
        function OnCurrentMileageChanged(s, e) {
            if (parseFloat(txt_CurrentMileageCtrl.GetText()) > 0 && parseFloat(txt_SendMileageCtrl.GetText()) > 0) {
                txt_ReturnMileageCtrl.SetText((parseFloat(txt_CurrentMileageCtrl.GetText()).toFixed(4)-0) + (parseFloat(txt_SendMileageCtrl.GetText()).toFixed(4)-0));
            }
        };
        function SaveCallback(s, e) {
            if (s.cpIsSucceed == true) {
                lpSaveCtrl.SetText('提交成功');
                btnSaveCtrl.SetEnabled(false);
                btnCancelCtrl.SetEnabled(false);
                parent.Search();
                window.setTimeout(function () { lpSaveCtrl.Hide(); lpSaveCtrl.SetText('正在提交信息,请稍后...'); }, 1500);
            } else {
                lpSaveCtrl.SetText('提交失败');
                btnSaveCtrl.SetEnabled(false);
                btnCancelCtrl.SetEnabled(false);
                window.setTimeout(function () { lpSaveCtrl.Hide(); lpSaveCtrl.SetText('正在提交信息,请稍后...'); }, 1500);
            }
        };
        function PlateNumChangeCallback(s, e) {
            HidFieldCtrl.Set('LastReturnMileage', s.cpLastReturnMileage)
            txt_SendMileageCtrl.SetText(s.cpLastReturnMileage);
            txt_CurrentMileageCtrl.SetText('');
            txt_ReturnMileageCtrl.SetText('');
        };
        function Save(s, e) {
            //PerformCallback参数格式为 是否补记|是否冲销|上次行车记录归还时里程
            //上次行车记录归还时里程
            var lastReturnMileage = HidFieldCtrl.Get("LastReturnMileage");
            if (ASPxClientEdit.ValidateEditorsInContainer(null)) {
                if (parseFloat(lastReturnMileage).toFixed(4) < parseFloat(txt_SendMileageCtrl.GetText()).toFixed(4)) {
                    ConfirmDialog('提示信息', '本次出车时里程大于上次归还时里程，是否要自动生成一条补记记录?', 250, 180,
                    function () {
                        cbSaveCtrl.PerformCallback('true|false|' + lastReturnMileage);
                        lpSaveCtrl.Show();
                        $(this).wijdialog('close');
                    },
                    function () {
                        cbSaveCtrl.PerformCallback('false|false|0');
                        lpSaveCtrl.Show();
                        $(this).wijdialog('close');
                    });
                }
                else if (parseFloat(lastReturnMileage).toFixed(4) > parseFloat(txt_SendMileageCtrl.GetText()).toFixed(4)) {
                    ConfirmDialog('提示信息', '本次出车时里程小于上次归还时里程，是否要自动生成一条冲销记录?', 250, 180,
                    function () {
                        cbSaveCtrl.PerformCallback('false|true|' + lastReturnMileage);
                        lpSaveCtrl.Show();
                        $(this).wijdialog('close');
                    },
                    function () {
                        cbSaveCtrl.PerformCallback('false|false|0');
                        lpSaveCtrl.Show();
                        $(this).wijdialog('close');
                    });
                }
                else {
                    cbSaveCtrl.PerformCallback('false|false|0');
                    lpSaveCtrl.Show();
                }
            }
        };
        //重置文本框
        function ResetEdit(s, e) {
            ASPxClientEdit.ClearEditorsInContainer(null);
            txt_UserNameCtrl.Focus();
            txt_UserCompanyCtrl.Focus();
            txt_DriverCtrl.Focus();
            txt_DirectionCtrl.Focus();
            txt_CauseCtrl.Focus();
            txt_PlateNumCtrl.Focus();
            lpSaveCtrl.SetText('正在提交信息,请稍后...');
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="MainRound">
        <div class="MainRoundContent">
            <div class="MainRoundContentW">
                <div class="MainBody">
                    <table class="Table" style="width: 740px">
                        <tr>
                            <td style="width: 120px">
                                车牌号码：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_PlateNum" runat="server" Width="200px" TabIndex="1" ClientInstanceName="txt_PlateNumCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus"
                                        TextChanged="OnPlateNumChanged" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入车牌号码"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入车牌号码">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                            <td style="width: 120px">
                                用车人：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_UserName" runat="server" Width="200px" TabIndex="2" ClientInstanceName="txt_UserNameCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入用车人"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入用车人">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                用车单位：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_UserCompany" runat="server" Width="200px" TabIndex="3" ClientInstanceName="txt_UserCompanyCtrl"
                                    Spacing="0" ClientIDMode="AutoID">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <Items>
                                        <dx:ListEditItem Text="本单位" Value="本单位" />
                                        <dx:ListEditItem Text="外单位" Value="外单位" />
                                    </Items>
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请选择用车单位"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请选择用车单位">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                            <td style="width: 120px">
                                人数：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_PeopleCount" ClientInstanceName="txt_PeopleCountCtrl" runat="server"
                                    MaxLength="4" NullText="请输入人数" TabIndex="4" Width="200px">
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                驾驶员：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_Driver" runat="server" Width="200px" TabIndex="5" ClientInstanceName="txt_DriverCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入驾驶员"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入驾驶员">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                            <td style="width: 120px">
                                去向：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_Direction" runat="server" Width="200px" TabIndex="6" ClientInstanceName="txt_DirectionCtrl"
                                    Spacing="0" DropDownStyle="DropDown" IncrementalFilteringMode="StartsWith" ClientIDMode="AutoID"
                                    ValueType="System.String" TextFormatString="{0}" ValueField="Value" DropDownRows="5">
                                    <Columns>
                                        <dx:ListBoxColumn FieldName="Key" Caption="去向" />
                                        <dx:ListBoxColumn FieldName="Value" Caption="行车路线" />
                                    </Columns>
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus"
                                        TextChanged="OnDirectionChanged" />
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入去向"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请输入去向">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                行车线路：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_DrivingLine" ClientInstanceName="txt_DrivingLineCtrl" runat="server"
                                    MaxLength="500" NullText="请输入行车线路" TabIndex="7" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入行车线路"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 120px">
                                用车事由：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxComboBox ID="txt_Cause" runat="server" Width="200px" TabIndex="8" ClientInstanceName="txt_CauseCtrl"
                                    Spacing="0" ClientIDMode="AutoID">
                                    <ClientSideEvents Init="DevExObj.OnInit" LostFocus="DevExObj.OnLostFocus" GotFocus="DevExObj.OnGotFocus" />
                                    <Items>
                                        <dx:ListEditItem Text="市内公务" Value="市内公务" />
                                        <dx:ListEditItem Text="外地公务" Value="外地公务" />
                                        <dx:ListEditItem Text="私人市内" Value="私人市内" />
                                        <dx:ListEditItem Text="私人长途" Value="私人长途" />
                                        <dx:ListEditItem Text="车辆外借" Value="车辆外借" />
                                        <dx:ListEditItem Text="上班通勤" Value="上班通勤" />
                                    </Items>
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请选择用车事由"
                                        ErrorFrameStyle-CssClass="TableNoBorder" ErrorText="请选择用车事由">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                出发时间：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxDateEdit ID="txt_SendTime" ClientInstanceName="txt_SendTimeCtrl" runat="server"
                                    TabIndex="9" NullText="请选择出发时间" Width="200px" Spacing="0" EditFormat="DateTime"
                                    PopupVerticalAlign="TopSides">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请选择出发时间"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxDateEdit>
                            </td>
                            <td style="width: 120px">
                                归还时间：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxDateEdit ID="txt_ReturnTime" ClientInstanceName="txt_ReturnTimeCtrl" runat="server"
                                    TabIndex="10" NullText="请选择归还时间" Width="200px" Spacing="0" PopupVerticalAlign="TopSides"
                                    EditFormat="DateTime">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请选择归还时间"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxDateEdit>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                出车时里程：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_SendMileage" ClientInstanceName="txt_SendMileageCtrl" runat="server"
                                    MaxLength="18" NullText="请输入出车时里程" TabIndex="11" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入出车时里程"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                    <ClientSideEvents TextChanged="OnSendMileageChanged" />
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 120px">
                                归还时里程：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_ReturnMileage" ClientInstanceName="txt_ReturnMileageCtrl"
                                    runat="server" MaxLength="18" NullText="请输入归还时里程" TabIndex="12" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入归还时里程"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                    <ClientSideEvents TextChanged="OnReturnMileageChanged" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 120px">
                                本次行驶里程：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_CurrentMileage" ClientInstanceName="txt_CurrentMileageCtrl"
                                    runat="server" MaxLength="18" NullText="请输入本次行驶里程" TabIndex="13" Width="200px">
                                    <ValidationSettings ErrorDisplayMode="ImageWithTooltip" RequiredField-ErrorText="请输入本次行驶里程"
                                        ErrorFrameStyle-CssClass="TableNoBorder">
                                        <RequiredField IsRequired="True" />
                                        <RegularExpression ErrorText="只能输入非负数字" ValidationExpression="^\d+(\.\d+)?$" />
                                    </ValidationSettings>
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                    <ClientSideEvents TextChanged="OnCurrentMileageChanged" />
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 120px">
                                备注：
                            </td>
                            <td style="width: 250px">
                                <dx:ASPxTextBox ID="txt_Remarks" ClientInstanceName="txt_RemarksCtrl" runat="server"
                                    MaxLength="250" NullText="请输入备注" TabIndex="14" Width="200px">
                                    <NullTextStyle ForeColor="LightSteelBlue" />
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table class="TableNoBorder" style="width: 740px">
                        <tr>
                            <td colspan="2" />
                            <td align="left" style="margin-right: 20px; width: 100px">
                                <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSaveCtrl" runat="server" Text="保  存"
                                    Width="80px" AutoPostBack="false" TabIndex="15">
                                    <ClientSideEvents Click="Save" />
                                </dx:ASPxButton>
                            </td>
                            <td align="left" style="margin-right: 20px; width: 100px">
                                <dx:ASPxButton ID="btnCancel" ClientInstanceName="btnCancelCtrl" runat="server" Text="重  置" Width="80px" AutoPostBack="false"
                                    TabIndex="16" CausesValidation="False">
                                    <ClientSideEvents Click="ResetEdit" />
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                    <dx:ASPxCallback ID="cbSave" runat="server" ClientInstanceName="cbSaveCtrl" OnCallback="cbSave_Callback">
                        <ClientSideEvents CallbackComplete="SaveCallback" />
                    </dx:ASPxCallback>
                    <dx:ASPxLoadingPanel ID="lpSave" runat="server" Text="正在提交信息,请稍后..." ClientInstanceName="lpSaveCtrl">
                    </dx:ASPxLoadingPanel>
                    <dx:ASPxCallback ID="cbPlateNum" runat="server" ClientInstanceName="cbPlateNumCtrl"
                        OnCallback="cbPlateNum_Callback">
                        <ClientSideEvents CallbackComplete="PlateNumChangeCallback" />
                    </dx:ASPxCallback>
                    <dx:ASPxHiddenField ID="HidField" ClientInstanceName="HidFieldCtrl" runat="server">
                    </dx:ASPxHiddenField>
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
